﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title>InfoBus Service</title>
		<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
		<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
		<META HTTP-EQUIV="Expires" CONTENT="0">
		<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=UTF-8">
		<style>
		    div{font-size:11px;font-family:verdana;}
		    td{font-size:11px;font-family:verdana;}
		    input{font-size:11px;font-family:verdana;}
		</style>
		<base target="_self">
		<!-- //CID //0749 //2010.8.30 //Init -->
	</head>
	<body style='padding: 0; margin: 0;' onload="DoLoad()">
		<script>
		var PictureWidth = 0;
		var PictureHeight = 0;
		//CID 0641 //2010.11.06 //Begin
		var opener = null;
		//CID 0641 //2010.11.06 //End
		var dsigData = null;
		var dSign = null;
		var usedCert = null;
		var browser = null;
		//CID 1504 //2012.12.23 //Begin
		var signedData = null;
		//CID 1504 //2012.12.23 //End
		function DoLoad() {
		    document.title = "Digital Signature";
		    var parent = window.dialogArguments[0];
			parent.InfoJet_CurrentDialog = window;
			//CID 0641 //2010.11.06 //Begin
			opener = parent;
			//CID 0641 //2010.11.06 //End
			var toSign = window.dialogArguments[2];
			if (toSign) {
			    browser = "Microsoft Internet Explorer";
			    dsigData = window.dialogArguments[1];
			    dSign = document.getElementById("DSign");
			    var output = dSign.ExchangeData(dsigData.Name, dsigData.Data, dsigData.Location, dsigData.Mode, dsigData.Message, dsigData.Xml, dsigData.Fingerprint, dsigData.ViewName, browser, dsigData.CtrlId);
			    var params = output.split("\n");
			    //CID 1538 //2013.01.11 //Begin
			    document.getElementById("DataName").innerHTML = dsigData.Name;
			    //CID 1538 //2013.01.11 //End
			    document.getElementById("DateTime").innerHTML = params[1];
			    document.getElementById("Fingerprint").innerHTML = dsigData.Fingerprint;
			    document.getElementById("ViewName").innerHTML = dsigData.ViewName;
			    document.getElementById("OS").innerHTML = params[2];
			    document.getElementById("Browser").innerHTML = browser;
			    document.getElementById("NrOfMonitors").innerHTML = params[3];
			    document.getElementById("PrimaryMonitor").innerHTML = params[4];

			    //CID 1536 //2013.01.09 //Begin
			    var htmlElement = parent.InfoBus_SignatureScreenInfo.documentElement;
			    //CID 1036 //2012.01.07 //Begin
			    var width = parent.InfoBus_SignatureScreenInfo.width;
			    var height = parent.InfoBus_SignatureScreenInfo.height;
			    //CID 1036 //2012.01.07 //End
			    //CID 1536 //2013.01.09 //End
			    dSign.width = width;
			    dSign.height = height;
			    dSign.CaptureHtmlElement(htmlElement, width, height);
			    //CID 1536 //2013.01.09 //Begin
			    parent.InfoBus_SignatureScreenInfo = null;
			    //CID 1536 //2013.01.09 //End
			} else {
			    document.getElementById("SignPart").style.display = "none";
			    document.getElementById("CommentTr").style.display = "";
			    document.getElementById("DataPart").style.marginLeft = "22px";

			    signedData = window.dialogArguments[1];
			    //CID 1021 //2011.11.18 //Begin
			    if (signedData.Status == "Valid") {
			        document.getElementById("DataLabel").innerHTML = "This signature is valid.";
			    } else if (signedData.Status == "Invalid") {
			        document.getElementById("DataLabel").innerHTML = "This signature is invalid.";
			    } else if (signedData.Status == "Error") {
			        document.getElementById("DataLabel").innerHTML = "There are errors in this signature.";
			    } else if (signedData.Status == "Revoked") {
			        document.getElementById("DataLabel").innerHTML = "This signature is revoked.";
			    } else if (signedData.Status == "NotTrusted") {
			        document.getElementById("DataLabel").innerHTML = "This signature is untrusted.";
			    } else if (signedData.Status == "Expired") {
			        document.getElementById("DataLabel").innerHTML = "This signature is expired.";
			    }
			    //CID 1021 //2011.11.18 //End
			    //CID 1538 //2013.01.11 //Begin
			    document.getElementById("DataName").innerHTML = signedData.Name;
			    //CID 1538 //2013.01.11 //End
			    document.getElementById("Comment").innerHTML = signedData.Comment;
			    document.getElementById("DateTime").innerHTML = signedData.DateTime;
			    document.getElementById("Fingerprint").innerHTML = signedData.Fingerprint;
			    document.getElementById("ViewName").innerHTML = signedData.ViewName;
			    document.getElementById("OS").innerHTML = signedData.OS;
			    document.getElementById("Browser").innerHTML = signedData.Browser; ;
			    document.getElementById("NrOfMonitors").innerHTML = signedData.NrOfMonitors;
			    document.getElementById("PrimaryMonitor").innerHTML = signedData.PrimaryMonitor;

			    document.getElementById("CertPart").style.display = "";
			    document.getElementById("ButtonPart").style.display = "";

			    dSign = document.getElementById("DSign");
			    dSign.SetScreenshot(signedData.Screenshot);
			    dSign.SetCert(signedData.Cert);
			}
        }
        function SelectCert() {
            dSign = document.getElementById("DSign");
            cert = dSign.SelectCert();
            if (cert != null) {
                var names = cert.split("\n");
                var selectedCert = document.getElementById("SelectedCert");
                var html = "Issued to " + names[0] + "<br>";
                html = html + "Issued by " + names[1] + "<br><br>";
                selectedCert.innerHTML = html;
                selectedCert.style.display = "";
                usedCert = cert;
                //CID 1537 //2013.01.10 //Begin
                var verifiedCheck = document.getElementById("VerifiedCheck");
                verifiedCheck.disabled = false;
                //CID 1537 //2013.01.10 //End
            }
            if (usedCert != null) {
                var selectCertButton = document.getElementById("SelectCertButton");
                selectCertButton.value = "Change certificate";
            }
        }
        //CID 1537 //2013.01.10 //Begin
        function OnVerifiedCheckClicked() {
            var verifiedCheck = document.getElementById("VerifiedCheck");
            if (verifiedCheck.checked) {
                var signButton = document.getElementById("SignButton");
                signButton.disabled = false;
            } else {
                var signButton = document.getElementById("SignButton");
                signButton.disabled = true;
            }
        }
        //CID 1537 //2013.01.10 //End
        function Sign() {
            var commentInput = document.getElementById("CommentInput").value;
            dSign = document.getElementById("DSign");
            var xml = dSign.Sign(commentInput);
            if (xml != null) {
                opener.InfoJet_OnSigned(dsigData.Name, xml);
                window.close();
            }
        }
        function ViewCert() {
            dSign.ShowCert();
        }
        function Cancel() {
            window.close();
        }
        //CID 1504 //2012.12.23 //Begin
        function Delete() {
            var signatureField = opener.document.getElementById(signedData.FieldId);
            opener.InfoJet_DeleteSignature(signatureField);
            window.close();
        }
        //CID 1504 //2012.12.23 //End
        //CID 1538 //2013.01.11 //Begin
        function ToggleMoreInfo() {
            var moreInfoToggle = document.getElementById("MoreInfoToggle");
            var fingerprintTr = document.getElementById("FingerprintTr");
            var osTr = document.getElementById("OSTr");
            var browserTr = document.getElementById("BrowserTr");
            var nrOfMonitorsTr = document.getElementById("NrOfMonitorsTr");
            var primaryMonitorTr = document.getElementById("PrimaryMonitorTr");
            if (fingerprintTr.style.display != "none") {
                fingerprintTr.style.display = "none";
                osTr.style.display = "none";
                browserTr.style.display = "none";
                nrOfMonitorsTr.style.display = "none";
                primaryMonitorTr.style.display = "none";
                moreInfoToggle.innerHTML = "View additional details";
            } else {
                fingerprintTr.style.display = "";
                osTr.style.display = "";
                browserTr.style.display = "";
                nrOfMonitorsTr.style.display = "";
                primaryMonitorTr.style.display = "";
                moreInfoToggle.innerHTML = "Hide additional details";
            }
        }
        //CID 1538 //2013.01.11 //End
		</script>
		<div id="DataPart" style="margin-left:15px;margin-top:15px;margin-right:15px">
		    <div id="DataLabel" style="font-weight:bold">
		        <span style="background-color:#0080C0;color:white;font-weight:bold;padding:1px 4px 1px 4px;">1</span>
                Verify the data that you will be signing
		    </div>
            <div style='margin-top:5px;height:1px;background-color:#cccccc;line-height:1px;clear:both;display:block;overflow:hidden'>
            </div>
            <div>
                &nbsp;
            </div>
            <table>
                <tr>
                    <td style="width:160px;">Date and time:</td><td><div id="DateTime"></div></td>
                </tr>
                <tr>
                    <td>Signed data name:</td><td><div id="DataName"></div></td>
                </tr>
                <tr>
                    <td>Current view:</td><td><div id="ViewName"></div></td>
                </tr>
                <tr id="CommentTr" style="display:none;">
                    <td>Comment:</td><td><div id="Comment"></div></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <a id="MoreInfoToggle" href="javascript:ToggleMoreInfo();" style="color:#0080C0;">View additional details</a>
                    </td>
                </tr>
                <tr id="FingerprintTr" style="display:none;">
                    <td>Form template fingerprint:</td><td><div id="Fingerprint"></div></td>
                </tr>
                <tr id="OSTr" style="display:none;">
                    <td>Windows version:</td><td><div id="OS"></div></td>
                </tr>
                <tr id="BrowserTr" style="display:none;">
                    <td>Browser:</td><td><div id="Browser"></div></td>
                </tr>
                <tr id="NrOfMonitorsTr" style="display:none;">
                    <td>Number of monitors:</td><td><div id="NrOfMonitors"></div></td>
                </tr>
                <tr id="PrimaryMonitorTr" style="display:none;">
                    <td>Primary monitor:</td><td><div id="PrimaryMonitor"></div></td>
                </tr>
            </table>
            <div>
                &nbsp;
            </div>
            <div id="CertPart" style="display:none;">
		        <input type="button" value="View Certificate" style="width:130px;" onclick="ViewCert();">
                <div>
                    &nbsp;
                </div>
            </div>
		    <div style="overflow-x:scroll;overflow-y:scroll;width:400;height:200;border:1px solid gray">
                <object id="DSign" height="1" width="1" classid="clsid:{B2E76105-8908-C543-18FE-A45416CE1DBF}"
						codebase="InfoBus Digital Signature.cab#version=1,0,0,0" VIEWASTEXT>
                </object>
            </div>
            <div>
                &nbsp;
            </div>
            <div id="ButtonPart" style="display:none;">
                <table style="width:400px;" cellspacing="0" cellpadding="0">
                    <tr>
                        <td>
                            <div style="float:left;text-align:left;display:inline-block;width:100%;">
                                <input type="button" value="Delete this signature" style="width:150px;" onclick="Delete();">
                            </div>
                        </td>
                        <td>
                            <div style="float:right;text-align:right;display:inline-block;width:100%;">
                                <input type="button" value="OK" style="width:70px;" onclick="Cancel();">
		                    </div>
                        </td>
                    </tr>
                </table>
                &nbsp;
            </div>
        </div>
        <div id="SignPart"  style="margin-left:15px;margin-bottom:15px;margin-right:15px">
            <div style="font-weight:bold">
		        <span style="background-color:#0080C0;color:white;font-weight:bold;padding:1px 4px 1px 4px;">2</span>
                Select a certificate
            </div>
            <div style='margin-top:5px;height:1px;background-color:#cccccc;line-height:1px;clear:both;display:block;overflow:hidden'>
            </div>
            <div>
                &nbsp;
            </div>
            <div id="SelectedCert" style="display:none;">
            </div>
            <div>
		        <input type="button" id="SelectCertButton" value="Select certificate" onclick="SelectCert();">
		    </div>
		    <div>
                &nbsp;
            </div>
            <div style="font-weight:bold">
		        <span style="background-color:#0080C0;color:white;font-weight:bold;padding:1px 4px 1px 4px;">3</span>
                Sign
            </div>
            <div style='margin-top:5px;height:1px;background-color:#cccccc;line-height:1px;clear:both;display:block;overflow:hidden'>
            </div>
            <div>
                &nbsp;
            </div>
            <div>
                Comments to include with your signature(optional):<br>
                <input type="text" id="CommentInput" value="" style="width:400px;"/>
		    </div>
            <div>
                &nbsp;
            </div>
            <div style="margin:5px;padding:5px;background-color:#F3E6F3;border: 1px solid #8888FF;">
                <input id="VerifiedCheck" type="checkbox" onclick="javascript:OnVerifiedCheckClicked();" disabled="disabled" value=""/>I have verified this content before signing
            </div>
            <div>
                &nbsp;
            </div>
            <div>
		        <input type="button" value="Sign" id="SignButton" disabled="true" style="width:70px;" onclick="Sign();">
		        <input type="button" value="Cancel" style="width:70px;" onclick="Cancel();">
		    </div>
		    <div>
                &nbsp;
            </div>
        </div>
	</body>
</html>
